package com.wanglianyun.listener;

import com.wanglianyun.event.RegisterSuccessEvent;
import com.wanglianyun.request.RegisterRequest;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * Description: RegisterSuccessEvent事件监听器，监听到RegisterSuccessEvent事件执行自己的逻辑
 * Copyright: Copyright (c) 2024
 * Create Time: 2024-09-26 19:42
 *
 * @author wanglianyun
 */
@Component
public class RegisterEventListener {

    //监听事件并异步执行
    @EventListener(RegisterSuccessEvent.class)
    @Async("registerSuccessExecutor")
    public void onApplicationEvent(RegisterSuccessEvent event) {
        RegisterRequest source = (RegisterRequest)event.getSource();
        System.out.println("得到监听的信息为：" + source.getMsg());
        System.out.println("已监听到信息，开始执行发送短信命令");
    }
}
